import random as r
from library import *
from statisticsFactory import *
r.seed(2011)

class Simulation():
    #population
    deathRate=0.3
    birthrate=0.8
    #economy        
    employmentRate=0.5
    firerate=0.3
    
    def __init__(self,inPopulation,inYears):
        self.pop=inPopulation
        for i in range(self.pop.year,(self.pop.year+inYears),1):
            #print "--",i,"--"
            #self.evaluateEconomy()
                 
            self.transition()
            print self.getStats()       
            
    
    def getStats(self):
        st=statisticsFactory(self.pop)
        sex = st.getStats(2)
        job = st.getStats(3)
        #age = st.getStats(1)
        string="year:%s, pop:%s, sex:%s, job:%s" %(self.pop.year, len(self.pop), sex,job)
        return string
        
    def transition(self):      
        #Year
        self.pop.year+=1
        
        #Death rate
        dice=float("%.2f"%r.random())
        if dice<=self.deathRate:
            self.pop=removePercentOfList(self.deathRate,self.pop)
        
        #Birth rate
        dice=float("%.2f"%r.random())
        if dice<=self.birthrate:
            self.pop=removePercentOfList(self.birthrate,self.pop)

        #apply hiring
        #self.pop=hirePercentageOfPop(self.pop, self.employmentRate)
        
        #apply buisiness closing
        
        #apply buisiness opening
        
        #apply hiring
